import cv2

from api.InternalConfig import *
from api.OCR_Words import getWords


def isNPCGive(img: cv2.Mat):
    """
    检测是否给专有给予
    :param img: 图像
    :return: True表示是
    """
    # 截取指定区域图像
    img = img[npcGiveHeightBounds[0]:npcGiveHeightBounds[1], npcGiveWidthBounds[0]:npcGiveWidthBounds[1]]
    # 获得
    r = getWords(img)
    ok = False
    if r[0] is not None:
        theWords = r[0][0][1][0]
        print(theWords)
        ok = "NPC给予专用界面" in theWords
    return ok


def getCurrentLocation(img: cv2.Mat):
    """
    获得当前所处的地方
    :param img: 图像
    :return: 地方
    """
    # 截取的目标图像
    purposeImg = img[locationHeightBounds[0]:locationHeightBounds[1], locationWidthBounds[0]:locationWidthBounds[1]]

    cv2.imshow("purposeImg", purposeImg)
    r = getWords(purposeImg)
    place = ""
    if len(r) > 0:
        place = r[0][0][1][0]
    print(place)
    cv2.waitKey()
